home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / BUSINESS / NONLIN15.ARJ / NONLIN.DOC < prev    next >
Text File  |  1992-08-06  |  91KB  |  1,804 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                                     N O N L I N
  11.  
  12.  
  13.  
  14.                        Nonlinear Regression Analysis Program
  15.  
  16.  
  17.  
  18.  
  19.                                 Phillip H. Sherrod
  20.  
  21.                                A "shareware" program
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.               Nonlin  allows  you  to  perform regression analyses to
  29.               estimate  the  values   of   parameters   for   linear,
  30.               multivariate,   polynomial,   and   general   nonlinear
  31.               functions.   The  regression  analysis  determines  the
  32.               values  of  the  parameters which cause the function to
  33.               best fit the observed data that you  provide.    Nonlin
  34.               allows you to specify the function whose parameters are
  35.               being estimated  using ordinary algebraic notation.  In
  36.               addition to determining the parameter estimates, Nonlin
  37.               can  be  directed  to  generate  an  output  file  with
  38.               predicted values  and  residuals.  It can also plot the
  39.               data observations and the computed function.   Although
  40.               designed  for  regression  analysis, Nonlin can also be
  41.               used to find the root (zero point) or minimum  absolute
  42.               value of  a  nonlinear expression.  Nonlin is in use at
  43.               many engineering and research centers around the world.
  44.  
  45.                NONLIN -- Nonlinear Regression Program       Page 1
  46.  
  47.  
  48.  
  49.  
  50.          INTRODUCTION TO REGRESSION ANALYSIS
  51.  
  52.          The  goal  of  regression  analysis is to determine the values of
  53.          parameters for a function that cause the function to best  fit  a
  54.          set of data observations that you provide.  In linear regression,
  55.          the function  is a linear (straight line) equation.  For example,
  56.          if we assume the value of an automobile decreases by  a  constant
  57.          amount  each  year  after its purchase, and for each mile driven,
  58.          the following  linear  function  would  predict  its  value  (the
  59.          dependent   variable)  as  a  function  of  the  two  independent
  60.          variables which are age and miles:
  61.  
  62.          value = price + depage*age + depmiles*miles
  63.  
  64.          where `value', the dependent variable, is the value of  the  car,
  65.          `age'  is  the age of the car, and `miles' is the number of miles
  66.          that the car has been driven.
  67.  
  68.          The regression analysis performed by Nonlin  will  determine  the
  69.          best values of the three parameters, `price', the estimated value
  70.          when  age  is  0  (i.e.,  when  the  car  was new), `depage', the
  71.          depreciation that takes place  each  year,  and  `depmiles',  the
  72.          depreciation for  each  mile  driven.  The values of `depage' and
  73.          `depmiles' will be negative because the car loses  value  as  age
  74.          and miles increase.
  75.  
  76.          In  a  problem  such  as  this car depreciation example, you must
  77.          provide a data file containing the values of  the  dependent  and
  78.          independent variables for a set of observations.  In this example
  79.          each  observation record would contain three numbers: value, age,
  80.          and miles, collected from used car ads for the  same  model  car.
  81.          The  more observations you provide, the more accurate will be the
  82.          estimate of the parameters.
  83.  
  84.          The Nonlin commands to perform this regression are shown below:
  85.  
  86.              VARIABLES VALUE,AGE,MILES
  87.              PARAMETERS PRICE,DEPAGE,DEPMILES
  88.              FUNCTION VALUE = PRICE + DEPAGE*AGE + DEPMILES*MILES
  89.              DATA
  90.              (data values go here)
  91.  
  92.          Once the values of the parameters are determined by  Nonlin,  you
  93.          can  use  the  formula to predict the value of a car based on its
  94.          age and miles driven.  For example, if Nonlin computed a value of
  95.          16000 for price, -1000 for depage, and -0.15 for  depmiles,  then
  96.          the function
  97.  
  98.          value = 16000 - 1000*age - 0.15*miles
  99.  
  100.                 NONLIN -- Nonlinear Regression Program       Page 2
  101.  
  102.  
  103.          could be used to estimate the value of a car with a known age and
  104.          number of miles.
  105.  
  106.          If a perfect fit existed between  the  function  and  the  actual
  107.          data,  the  actual  value  of  each  car  in your data file would
  108.          exactly equal the predicted value.  Typically, however,  this  is
  109.          not  the case, and the difference between the actual value of the
  110.          dependent variable and  its  predicted  value  for  a  particular
  111.          observation  is  the  error of the estimate which is known as the
  112.          "deviation" or "residual".  The goal of regression analysis is to
  113.          determine the values of the parameters which minimize the sum  of
  114.          the squared residual values for the set of observations.  This is
  115.          known as a "least squares" regression fit.
  116.  
  117.  
  118.          INTRODUCTION TO NONLIN
  119.  
  120.          Nonlin is  a very powerful regression analysis program.  Using it
  121.          you can perform multivariate,  linear,  polynomial,  and  general
  122.          nonlinear regression.    What  this means is that you specify the
  123.          form of the function to be fitted to the data, and  the  function
  124.          can  include  nonlinear  terms such as variables raised to powers
  125.          and library  functions  such  as  log,  exponential,  sine,  etc.
  126.          Nonlin uses a state-of-the-art regression algorithm that works as
  127.          well,  or  better,  than any you are likely to find in commercial
  128.          statistical packages.
  129.  
  130.          As  an  example  of  nonlinear   regression,   consider   another
  131.          depreciation problem.  The value of a used airplane decreases for
  132.          each year of its age.  Assuming the value of a plane falls by the
  133.          same  amount  each  year, a linear function relating value to age
  134.          is:
  135.  
  136.               Value = p0 + p1*Age
  137.  
  138.          Where `p0' and `p1' are the parameters whose  values  are  to  be
  139.          determined.   However,  it  is a well known fact that planes (and
  140.          automobiles) lose more value the first year than the second,  and
  141.          more the  second  than  the third, etc.  This means that a linear
  142.          (straight line) function cannot accurately model this  situation.
  143.          A better, nonlinear, function is:
  144.  
  145.               Value = p0 + p1*exp(-p2*Age)
  146.  
  147.          Where  the `exp' function is the value of e (2.7182818...) raised
  148.          to a power.    This  type  of  function  is  known  as  "negative
  149.          exponential"  and  is appropriate for modeling a value whose rate
  150.          of decrease is proportional to the difference between  the  value
  151.          and some base value.  The F33YEAR.NLR example command file fits a
  152.          linear function  to  the value of used airplanes.  The F33EXP.NLR
  153.          example fits a negative exponential function to  the  same  data.
  154.          Run both  examples and compare the fitted functions.  See F33.NLR
  155.          for an example of a multiple regression using  three  independent
  156.  
  157.                 NONLIN -- Nonlinear Regression Program       Page 3
  158.  
  159.  
  160.          variables.
  161.  
  162.          Much of the convenience of Nonlin comes from the  fact  that  you
  163.          can   enter   complicated   functions  using  ordinary  algebraic
  164.          notation.  Examples of functions that can be handled with  Nonlin
  165.          include:
  166.  
  167.          Linear: Y = p0 + p1*X
  168.  
  169.          Quadratic: Y = p0 + p1*X + p2*X^2
  170.  
  171.          Multivariate: Y = p0 + p1*X + p2*Z + p3*X*Z
  172.  
  173.          Exponential: Y = p0 + p1*exp(X)
  174.  
  175.          Periodic: Y = p0 + p1*sin(p2*X)
  176.  
  177.          Misc: Y = p0 + p1*Y + p2*exp(Y) + p3*sin(Z)
  178.  
  179.          In  other  words,  the function is a general expression involving
  180.          one dependent variable (on the left of the equal  sign),  one  or
  181.          more  independent  variables,  and  one  or more parameters whose
  182.          values are to be estimated.
  183.  
  184.          Because  of  its  generality,  Nonlin  can  perform  all  of  the
  185.          regressions handled by ordinary linear or multivariate regression
  186.          programs as  well  as nonlinear regression.  However, in order to
  187.          handle nonlinear functions, Nonlin  uses  an  iterative  function
  188.          optimization  algorithm  which  is  slower than the simple linear
  189.          regression algorithm and has the potential for not converging  to
  190.          a solution.
  191.  
  192.  
  193.          INSTALLING NONLIN
  194.  
  195.          The NONLIN system consists of the following files:
  196.  
  197.            NONLIN.EXE -- The executable program.
  198.            NONLIN.DOC -- Documentation file.
  199.            NONLIN.FON -- Font file used if you request a plot.
  200.            NONLIN.LJF -- HP LaserJet font file used if you print a plot.
  201.                 *.NLR -- Example command files.
  202.          REGISTER.DOC -- Form used to register your use of Nonlin.
  203.  
  204.          To  install  Nonlin,  copy  the  files into the directory of your
  205.          choice.  If you do not plan to generated hard copy output  for  a
  206.          LaserJet printer,  you  may  delete  the NONLIN.LJF file.  If the
  207.          NONLIN.FON  and  NONLIN.LJF  files  are  not  in   your   current
  208.          directory, you must place a command of the following form in your
  209.          AUTOEXEC.BAT  file  to  tell  Nonlin  where  to look for its font
  210.          files:
  211.  
  212.                NONLIN -- Nonlinear Regression Program       Page 4
  213.  
  214.  
  215.          SET NONLIN=directory
  216.  
  217.          Where  "directory"  is the name of the device and directory where
  218.          the files are located.  For example, if the files are located  in
  219.          a  directory  named  NONLIN  on the C disk, the following command
  220.          could be used:
  221.  
  222.          SET NONLIN=C:\NONLIN
  223.  
  224.  
  225.          USING NONLIN
  226.  
  227.          Once Nonlin has been installed, it can be  started  using  a  DOS
  228.          command of the form:
  229.  
  230.          NONLIN command_file [listing_file]
  231.  
  232.          where  "command_file"  is  the  name  of a file containing Nonlin
  233.          commands that control the analysis.   The  sections  that  follow
  234.          describe these  commands.    If  you  specify a command file name
  235.          without an extension, ".NLR" is used as  the  default  extension.
  236.          If  you  omit  the command file name, Nonlin prints a list of its
  237.          commands.
  238.  
  239.          A "listing_file" parameter may be specified on the command  line.
  240.          If  you  specify  a  file  name,  the  output  (results)  of  the
  241.          regression analysis are written to this file.  If no file name is
  242.          specified, the output is written to a file with the same name  as
  243.          the command_file but with the extension ".LST".  If you specify a
  244.          listing file name without an extension, ".LST" is provided as the
  245.          default extension.    Specify  NUL for the listing_file if you do
  246.          not want to generate an output file.
  247.  
  248.          For  example,  to  process  a  command  file  named   LINEAR.NLR,
  249.          directing  output  to  a file named LINEAR.LST, use the following
  250.          command:
  251.  
  252.          NONLIN LINEAR
  253.  
  254.          To do the same analysis, directing the output  to  a  file  named
  255.          MODEL1.LST, use the following command:
  256.  
  257.          NONLIN LINEAR MODEL1
  258.  
  259.          At  this  point,  I  suggest  you  pause  in your reading and try
  260.          running a Nonlin example to get a feel for how it works.  Several
  261.          example files with the extension ".NLR"  are  provided  with  the
  262.          distribution.  LINEAR.NLR is a good one to start with.  If you do
  263.          not  have  a  graphics  monitor, edit the LINEAR.NLR command file
  264.          (and other example files) and remove the PLOT command.
  265.  
  266.                NONLIN -- Nonlinear Regression Program       Page 5
  267.  
  268.  
  269.          FUNCTION SPECIFICATION
  270.  
  271.          Much  of  the  power of Nonlin comes from its ability to estimate
  272.          the value of parameters that are part  of  complicated  functions
  273.          that you enter in ordinary algebraic form.  This section explains
  274.          the  arithmetic operators and built in functions that are used to
  275.          specify a function.
  276.  
  277.          Arithmetic Operators
  278.  
  279.          The following arithmetic operators may be used in expressions:
  280.  
  281.              +        addition
  282.              -        subtraction or unary minus
  283.              *        multiplication
  284.              /        division
  285.              ** or ^  exponentiation
  286.  
  287.          Exponentiation  has   the   highest   precedence,   followed   by
  288.          multiplication  and  division, and then addition and subtraction.
  289.          Parentheses may be used to group terms.
  290.  
  291.          As a convenience, Nonlin allows you to  omit  the  multiplication
  292.          operator  between  a  numeric  constant and a following variable,
  293.          parameter, or function.  For example, the expressions "2pi",  and
  294.          "2 pi" are  equivalent  to "2*pi".  Similarly, "5X" is equivalent
  295.          to "5*X".  However, if you specify a  number  before  the  letter
  296.          "E",  it  will  be taken as the exponential form of a number (see
  297.          below) rather than the number  times  the  constant  e  (base  of
  298.          natural logarithms).
  299.  
  300.          Numeric Constants
  301.  
  302.          Numeric  constants  may  be  written in their natural form (1, 0,
  303.          1.5, .0003, etc.) or in exponential form, n.nnnEppp, where  n.nnn
  304.          is  the  base value and ppp is the power of ten by which the base
  305.          is multiplied.  For example, the number 1.5E4  is  equivalent  to
  306.          15000.   All  numbers  are  treated  as  "floating point" values,
  307.          regardless of whether a decimal point is specified or not.  As  a
  308.          convenience  for entering time values, if a value contains one or
  309.          more colons, the portion to the left of the colon  is  multiplied
  310.          by 60.    For  example,  1:00  is  equivalent  to  60; 1:00:00 is
  311.          equivalent to 3600.
  312.  
  313.          Symbolic Constants
  314.  
  315.          You can use the CONSTANT command to associate symbolic names with
  316.          constant numeric values.  When you use the symbolic name  in  the
  317.          function the numeric value is substituted for the symbolic name.
  318.  
  319.                 NONLIN -- Nonlinear Regression Program       Page 6
  320.  
  321.  
  322.          Built-in Constants
  323.  
  324.          There are two built-in numeric constants that  may  be  specified
  325.          using symbolic  names.    The symbolic name "PI" is equivalent to
  326.          the value of pi, 3.14159...  Similarly, the symbolic constant "E"
  327.          is equivalent to the base of natural logarithms, e,  2.7182818...
  328.          You may write PI and E using either upper or lower case.
  329.  
  330.  
  331.          Built in Functions
  332.  
  333.          The  following functions are built into Nonlin and may be used in
  334.          expressions:
  335.  
  336.          ABS(x) -- Absolute value of x.
  337.  
  338.          ACOS(x) -- Arc cosine of x.  Angles are measured in radians.
  339.  
  340.          ASIN(x) -- Arc sine of x.  Angles are measured in radians.
  341.  
  342.          ATAN(x) -- Arc tangent of x.  Angles are measured in radians.
  343.  
  344.          BETAI(x,a,b) --  Incomplete  beta   function:   Ix(a,b).      The
  345.               incomplete beta function can be used to compute a variety of
  346.               statistical functions.    For  example,  the  probability of
  347.               Student's t with `df' degrees of  freedom  can  be  computed
  348.               with BETAI(df/(df+t^2),.5*df,.5).   The probability of the F
  349.               statistic with  df1  and  df2  degrees  of  freedom  can  be
  350.               computed with 2*BETAI(df2/(df2+df1*f),.5*df2,.5*df1).
  351.  
  352.          COS(x) -- Cosine of x.  Angles are measured in radians.
  353.  
  354.          COSH(x) -- Hyperbolic cosine of x.
  355.  
  356.          COT(x) -- Cotangent of x. (COT(x) = 1/TAN(x)).  Angle in radians.
  357.  
  358.          CSC(X) -- Cosecant of x. (CSC(x) = 1/SIN(x)).  Angle in radians.
  359.  
  360.          DEG(x)  --  Converts  an  angle,  x,  measured  in radians to the
  361.               equivalent number of degrees.
  362.  
  363.          EI1(alpha,phi) -- Elliptic integral of the first kind.   Computes
  364.               the   integral  from  0  to  phi  radians  of  the  function
  365.               d.phi/sqrt(1-k**2*sin(phi)**2), where k = sin(alpha).  alpha
  366.               and phi must be in the range 0 to pi/2.
  367.  
  368.          EI2(alpha,phi) -- Elliptic integral of the second kind.  Computes
  369.               the   integral  from  0  to  phi  radians  of  the  function
  370.               sqrt(1-k**2*sin(phi)**2)*d.phi, where k = sin(alpha).  alpha
  371.               and phi must be in the range 0 to pi/2.
  372.  
  373.                NONLIN -- Nonlinear Regression Program       Page 7
  374.  
  375.  
  376.          EIC1(alpha)  --  Complete  elliptic  integral  of the first kind.
  377.               Computes the integral from 0 to pi/2 radians of the function
  378.               d.phi/sqrt(1-k**2*sin(phi)**2),  where k = sin(alpha). alpha
  379.               must be in the range 0 to (less than) pi/2.
  380.  
  381.          EIC2(alpha) -- Complete elliptic integral  of  the  second  kind.
  382.               Computes the integral from 0 to pi/2 radians of the function
  383.               sqrt(1-k**2*sin(phi)**2)*d.phi,  where k = sin(alpha). alpha
  384.               must be in the range 0 to pi/2.
  385.  
  386.          ERF(x) -- Standard error function of x.
  387.  
  388.          EXP(x) -- e (base of natural logarithms) raised to the x power.
  389.  
  390.          FAC(x) -- x factorial (x!).  Note, the FAC function  is  computed
  391.               using  the GAMMA function (FAC(x)=GAMMA(x+1)) so non-integer
  392.               argument values may be computed.
  393.  
  394.          GAMMA(x) -- Gamma function.  Note, GAMMA(x+1) = x! (x factorial).
  395.  
  396.          GAMMAI(x)  --  Reciprocal  of   GAMMA   function   (GAMMAI(x)   =
  397.               1/GAMMA(x)).
  398.  
  399.          GAMMALN(x) -- Log (base e) of the GAMMA function.
  400.  
  401.          HAV(x) --  Haversine  of  x.  (HAV(x) = (1-COS(x))/2).   Angle in
  402.               radians.
  403.  
  404.          J0(x) -- Bessel function of the first kind, order zero.
  405.  
  406.          J1(x) -- Bessel function of the first kind, order one.
  407.  
  408.          JN(n,x) -- Bessel function of the first kind, order n.
  409.  
  410.          LOG(x) -- Natural logarithm of x.
  411.  
  412.          LOG10(x) -- Base 10 logarithm of x.
  413.  
  414.          LOG2(x) -- Base 2 logarithm of x.
  415.  
  416.          MAX(x1,x2) -- Maximum value of x1 or x2.
  417.  
  418.          MIN(x1,x2) -- Minimum value of x1 or x2.
  419.  
  420.          NORMAL(x) -- Normal probability distribution of x.  X is in units
  421.               of standard deviations from the mean.
  422.  
  423.          PAREA(x) -- Area under the normal probability distribution  curve
  424.               from  -infinity to x. (i.e., integral from -infinity to x of
  425.               NORMAL(x)).
  426.  
  427.                NONLIN -- Nonlinear Regression Program       Page 8
  428.  
  429.  
  430.          PULSE(a,x,b) -- Pulse function.  If the value of x is less than a
  431.               or greater  than b, the value of the function is 0.  If x is
  432.               greater than or equal to a and less than or equal to b,  the
  433.               value of the function is 1.  In other words, it is 1 for the
  434.               domain (a,b)  and  zero  elsewhere.   If you need a function
  435.               that is zero in the domain (a,b) and 1  elsewhere,  use  the
  436.               expression (1-PULSE(a,x,b)).
  437.  
  438.          RAD(x) -- Converts an angle measured in degrees to the equivalent
  439.               number of radians.
  440.  
  441.          SEC(x) -- Secant of x. (SEC(x) = 1/COS(x)).  Angle in radians.
  442.  
  443.          SEL(a1,a2,v1,v2)  --  If a1 is less than a2 then the value of the
  444.               function is v1.  If a1 is greater than or equal to a2,  then
  445.               the value of the function is v2.
  446.  
  447.          SIN(x) -- Sine of x.  Angles are measured in radians.
  448.  
  449.          SINH(x) -- Hyperbolic sine of x.
  450.  
  451.          SQRT(x) -- Square root of x.
  452.  
  453.          STEP(a,x) --  Step  function.   If x is less than a, the value of
  454.               the function is 0.  If x is greater than or equal to a,  the
  455.               value of the function is 1.  If you need a function which is
  456.               1  up  to  a certain value and then 0 beyond that value, use
  457.               the expression STEP(x,a).  See PIECE.NLR for an  example  of
  458.               this function.
  459.  
  460.          T(n,x) -- Chebyshev polynomial of order n.
  461.  
  462.          TAN(x) -- Tangent of x.  Angles are measured in radians.
  463.  
  464.          TANH(x) -- Hyperbolic tangent of x.
  465.  
  466.          Y0(x) -- Bessel function of the second kind, order zero.
  467.  
  468.          Y1(x) -- Bessel function of the second kind, order one.
  469.  
  470.          YN(n,x) -- Bessel function of the second kind, order n.
  471.  
  472.                 NONLIN -- Nonlinear Regression Program       Page 9
  473.  
  474.  
  475.          NONLIN COMMAND FILES
  476.  
  477.          The commands described in this section are placed  in  a  command
  478.          file.  When you start Nonlin, you specify the name of the command
  479.          file as  a  parameter  on  the command line.  For example, if the
  480.          command file name is CAR.NLR, the following command  would  cause
  481.          Nonlin to execute the commands in the command file:
  482.  
  483.          NONLIN CAR.NLR
  484.  
  485.          If you do not specify a file name extension for the command file,
  486.          ".NLR" is used by default.  The output of the regression for this
  487.          example  would  be written to a file named CAR.LST. Command files
  488.          can be created using a text editor such as  EDIT-32,  EDLIN,  the
  489.          DOS version 5 EDIT program, or any other editor or word processor
  490.          that is capable of creating an ascii text file without formatting
  491.          codes.
  492.  
  493.          Comments  may be placed in command files by preceding the comment
  494.          with an exclamation point.  Entire lines may be used for comments
  495.          and comments can be placed at the end of commands.
  496.  
  497.          Command lines can be continued by placing a  semicolon  character
  498.          as the last non-blank character on the line (a comment may follow
  499.          the  semicolon)  and then continuing the command on the following
  500.          line(s).
  501.  
  502.          Every  command  file  must  contain   the   following   commands:
  503.          VARIABLES,  PARAMETERS,  FUNCTION,  and  DATA. The DATA statement
  504.          introduces the data for the analysis and must be the last command
  505.          in the file (data records  may  follow  it).    Other,  optional,
  506.          commands may be interspersed in the command file.
  507.  
  508.          The following is an example of a complete command file:
  509.  
  510.              VARIABLES  VALUE,AGE,MILES
  511.              PARAMETERS BASE,DEPAGE,DEPMILES
  512.              FUNCTION VALUE = BASE + DEPAGE*AGE + DEPMILES*MILES
  513.              DATA
  514.              (data records follow)
  515.  
  516.  
  517.          NONLIN COMMANDS
  518.  
  519.          The  following is a list of the valid Nonlin commands that can be
  520.          placed in a  Nonlin  command  file.    Command  keywords  may  be
  521.          abbreviated  to  the  first  three  letters  except for CONSTANT,
  522.          CONSTRAIN, and CONFIDENCE which  require  six  letters.    Nonlin
  523.          commands are not case sensitive.
  524.  
  525.                 NONLIN -- Nonlinear Regression Program      Page 10
  526.  
  527.  
  528.          TITLE string (optional) -- Specifies a title line that is printed
  529.               with the results of the analysis.
  530.  
  531.          VARIABLES var1,var2,... (required) -- Specifies the names of  the
  532.               variables that  will be used in the function.  The dependent
  533.               variable and the independent variables  must  be  specified.
  534.               The  order of the variable names must match the order of the
  535.               data  values  on  each  observation  record  (the  dependent
  536.               variable   may   come   before   or  after  the  independent
  537.               variables).  You may define more variables than you actually
  538.               use in  the  function  specification.    A  maximum  of   12
  539.               variables may  be  specified.  The length of a variable name
  540.               is limited to 10 characters.  Capitalize the variable  names
  541.               as you want them displayed in the results.
  542.  
  543.               You  may  specify  all  of the variables on a single command
  544.               line (which may be  continued),  or  you  may  use  multiple
  545.               VARIABLES commands.  If you use multiple commands, the order
  546.               in  which  they  appear  in  the command file must match the
  547.               order of the variable values  on  each  observation  record.
  548.               The  VARIABLES  command  must  precede the FUNCTION command.
  549.               See F33.NLR for an example of a  multiple  regression  using
  550.               three independent variables.
  551.  
  552.          PARAMETERS param1[=initial1],param2[=initial2],...  (required) --
  553.               Specifies the names of the parameters whose values are to be
  554.               determined by Nonlin.  Nonlin is capable of handling  up  to
  555.               12 parameters.    The  parameter  names  may  not  exceed 10
  556.               characters in length.  Do not specify  any  parameters  that
  557.               are not  used  in the function.  The PARAMETERS command must
  558.               precede the FUNCTION command.
  559.  
  560.               Optionally, an initial estimate of the parameter  value  may
  561.               be  specified  by following the parameter name with an equal
  562.               sign and the value.  If no value is specified, 1 is used  by
  563.               default.   Specifying  an  initial  value  that  is near the
  564.               actual value usually speeds up the operation of  Nonlin  and
  565.               may enable  it  to  successfully converge to a solution.  If
  566.               Nonlin is unable to converge to a solution,  try  specifying
  567.               different starting  values  for  the  parameters.    Try  to
  568.               specify a value that at least has the correct  sign  as  the
  569.               expected final value.
  570.  
  571.               The CONSTRAIN command (described below) can be used to limit
  572.               the range  of  values for parameters.  The SWEEP command can
  573.               be used to perform the regression analysis with a  range  of
  574.               parameter initial  values.  The CONSTANT command can be used
  575.               to define a parameter with a fixed value.
  576.  
  577.                 NONLIN -- Nonlinear Regression Program      Page 11
  578.  
  579.  
  580.          CONFIDENCE [percent] (optional) -- Specifies  that  a  confidence
  581.               interval is to be printed for each estimated parameter.  The
  582.               purpose of regression analysis  is  to  determine  the  best
  583.               estimate of   parameter  values.    However,  as  with  most
  584.               statistical  calculations,   the   values   determined   are
  585.               estimates of the true values.  The CONFIDENCE command causes
  586.               Nonlin to print a table showing the range of possible values
  587.               for each  parameter given a specified confidence value.  The
  588.               "percent" parameter spcifies the probability that  that  the
  589.               actual  value  of  the  parameter  is  within the confidence
  590.               interval to be computed.  For example, the command
  591.  
  592.               CONFIDENCE 95
  593.  
  594.               specifies that the confidence interval(s) are to be computed
  595.               such that there is a 95 percent probability that the  actual
  596.               values  of  the parameters are within the intervals (or that
  597.               there is a 5 percent chance that the parameters are  outside
  598.               the intervals).    The "percent" parameter may range from 50
  599.               to 99.999.   If  the  CONFIDENCE  command  is  used  without
  600.               specifiying a percent value, 90 is used by default.
  601.  
  602.          CONSTANT parameter=value  (optional)  --  Specifies the name of a
  603.               symbolic constant and associates a numeric value.   You  may
  604.               then   use  the  symbolic  name  in  the  function  and  the
  605.               corresponding constant numeric value  will  be  substituted.
  606.               This  is useful when you are trying out different models and
  607.               want to easily be able to change a constant value  for  each
  608.               run.   The  CONSTANT  commands  must  precede  the  FUNCTION
  609.               command.  The following is an example of a symbolic constant
  610.               named "Roomtemp" that causes the value 73 to be  substituted
  611.               in the function:
  612.  
  613.               Variable Time            ! Cooling time in seconds
  614.               Variable Temp            ! Temperature of object in degrees farenheit
  615.               Constant Roomtemp = 73        ! Ambient (room) temperature was 73 degrees F
  616.               Parameter InitTemp        ! Initial temperature of object above room temp
  617.               Parameter Coolrate        ! Exponential cooling rate factor
  618.               Function Temp = Roomtemp + InitTemp * exp(-Coolrate * Time)
  619.  
  620.          CONSTRAIN parameter=lowvalue,highvalue  (optional) -- Specifies a
  621.               lower and upper limit on the range  of  a  parameter  value.
  622.               During  the solution process, Nonlin may allow a parameter's
  623.               value to temporarily move in a direction away from its final
  624.               value.  With some functions it may be necessary to constrain
  625.               the parameter's value so that it does not go negative (e.g.,
  626.               if the function takes the square root of the parameter),  or
  627.               zero (if the parameter is in a denominator).  If a parameter
  628.               is   tightly   constrained,   Nonlin  may  report  "singular
  629.               convergence" because it is unable to converge to an  optimum
  630.               value  of  the  parameter;  however, the estimated values of
  631.               other parameters may be useful.
  632.  
  633.                 NONLIN -- Nonlinear Regression Program      Page 12
  634.  
  635.  
  636.               Only a single parameter and its  associated  limits  may  be
  637.               specified  on  each  CONSTRAIN  command,  but  you  may  use
  638.               multiple CONSTRAIN  commands.    The PARAMETERS command must
  639.               precede the CONSTRAIN command.  Use the CONSTANT command  if
  640.               you wish to define a parameter with a fixed value.
  641.  
  642.               The  parameter  value is allowed to range from `lowvalue' to
  643.               `highvalue'.  If you want to prevent a parameter value  from
  644.               going  to  zero,  you must specify a value greater than zero
  645.               for the low value (specifying zero would allow it to  reach,
  646.               but not go below, zero).  For example, the following command
  647.               constrains  the  value  of `age' to be greater than zero and
  648.               less than or equal to 100:
  649.  
  650.               CONSTRAIN age = .0001,100
  651.  
  652.               See the COOLING.NLR, F33EXP.NLR,  and  POWER.NLR  files  for
  653.               examples of the CONSTRAIN command.
  654.  
  655.          COVARIANCE  (optional)  --  Causes the variance-covariance matrix
  656.               for the parameters to be printed.
  657.  
  658.          SWEEP parameter=lowvalue,highvalue,stepsize  (optional)        --
  659.               Specifies  that  the  regression analysis is to be performed
  660.               repeatedly with a set of starting values for the  parameter.
  661.               The  first  analysis  is performed with the parameter having
  662.               the `lowvalue'; the value of `stepsize' is then added to the
  663.               parameter's initial value  and  the  analysis  is  performed
  664.               again.   The  process  is  repeated  until  the value of the
  665.               parameter reaches `highvalue'.
  666.  
  667.               Each time  the  analysis  is  performed  the  value  of  the
  668.               residual  sum  of squares is compared with the best previous
  669.               result.  The estimated values of the parameters for the best
  670.               starting value are saved and used for the final analysis and
  671.               report.
  672.  
  673.               Only one parameter may be specified on each  SWEEP  command,
  674.               but  you  may  have  as  many  SWEEP  commands  as there are
  675.               parameters.  The number  of  regression  analyses  performed
  676.               will  be  equal  to  the  product of the number of parameter
  677.               values for each SWEEP command.
  678.  
  679.               The SWEEP command is useful when you are  trying  to  fit  a
  680.               complicated  function  that  may have "local minimum" values
  681.               other than the "global minimum".  Periodic  functions  (sin,
  682.               cos, etc.) are especially troublesome.
  683.  
  684.               See  the  SINE.NLR  command file for an example of the SWEEP
  685.               command.
  686.  
  687.                 NONLIN -- Nonlinear Regression Program      Page 13
  688.  
  689.  
  690.          FUNCTION depvar = function  (required) -- Specifies the  form  of
  691.               the function whose parameters are to  be  determined.    The
  692.               dependent variable must be the only thing to the left of the
  693.               equal sign.    The expression to the right of the equal sign
  694.               may contain variables, parameters, constants, operators, and
  695.               library functions  such  as  sqrt,  sin,  exp,  etc.     The
  696.               VARIABLES  and PARAMETERS commands must have appeared in the
  697.               command file before the FUNCTION command, and all  variables
  698.               and parameters used in the function must have been specified
  699.               on those  commands.  Some example FUNCTION commands are show
  700.               below:
  701.  
  702.               FUNCTION Y = P0 + P1*X
  703.  
  704.               FUNCTION DISTANCE = .5 * ACCEL * TIME^2
  705.  
  706.               FUNCTION VALUE = PRICE + YRDEP*AGE + MILEDEP*MILES
  707.  
  708.               FUNCTION POPULATN = BASE * GROWRATE * EXP(TIME)
  709.  
  710.          TOLERANCE value  (optional,  default=1E-10)  --   Specifies   the
  711.               tolerance   factor  that  is  used  to  determine  when  the
  712.               algorithm has  converged  to  a  solution.    Reducing   the
  713.               tolerance  value may produce a slightly more accurate result
  714.               but will increase the number of iterations and  the  running
  715.               time.
  716.  
  717.          ITERATIONS value  (optional, default=50) -- Specifies the maximum
  718.               number  of  iterations  that  should  be  attempted  by  the
  719.               algorithm.   If  the solution does not converge to the limit
  720.               specified by  the  TOLERANCE  command  (or  to  the  default
  721.               tolerance)  before  the  maximum  number  of  iterations  is
  722.               reached, the process is stopped and the results are printed.
  723.               Failure  to  converge  before  the   specified   number   of
  724.               iterations could be caused by one of three things:
  725.  
  726.               1. The  maximum  allowed  number  of  iterations  may be too
  727.               small.  Try using an ITERATIONS command with a larger value.
  728.  
  729.               2. The tolerance factor may be too small.  Even  a  properly
  730.               converging solution will eventually "level off" or oscillate
  731.               around a  good,  but  non-zero,  sum  of squares value.  Try
  732.               using the TOLERANCE command to increase the tolerance value.
  733.  
  734.               3. The function may  not  be  converging.    Try  specifying
  735.               better  (or  at  least  different)  starting  values for the
  736.               parameters on the PARAMETERS command.   Consider  using  the
  737.               SWEEP  command  to  specify  a  range  of parameter starting
  738.               values.
  739.  
  740.                 NONLIN -- Nonlinear Regression Program      Page 14
  741.  
  742.  
  743.          REGISTER  (optional)  --  The  REGISTER  command  suppresses  the
  744.               copyright and registration message that is normally  printed
  745.               as part  of  a  Nonlin report.  The use of this command is a
  746.               reminder that you should register your use of Nonlin.  Note,
  747.               if  you  find  Nonlin  to   be   useful,   educational,   or
  748.               entertaining  you  are expected to register your use so that
  749.               the author can be justly compensated and that development of
  750.               the program can continue.  Use the form in  REGISTER.DOC  to
  751.               register your use.
  752.  
  753.          OUTPUT [TO file] var1,var2,... (optional) -- Specifies that after
  754.               the  analysis is completed, data values are to be printed or
  755.               written to a file.  If the "TO file" portion of the  command
  756.               is  specified,  the output is written to the specified file.
  757.               If this portion of the command is omitted, the output values
  758.               are printed along with the results.    If  a  file  name  is
  759.               specified without an extension, ".OUT" is used by default.
  760.  
  761.               The  list  of  variable names determines which variables are
  762.               written to the file and the order in which the values appear
  763.               in each output record.  Any variable previously declared  on
  764.               a VARIABLES  command  may  be  specified.   In addition, the
  765.               folowing special variable names may  appear  in  the  output
  766.               list:
  767.  
  768.               $OBS  --  The  observation  record number, starting at 1 and
  769.               increasing by 1.
  770.  
  771.               $PREDICTED -- The predicted value for the dependent variable
  772.               for the observation, given the independent  variable  values
  773.               and the parameters as calculated by the analysis.
  774.  
  775.               $RESIDUAL  -- The difference between the actual value of the
  776.               dependent variable and its predicted value.
  777.  
  778.               Examples of OUTPUT commands are shown below:
  779.  
  780.               OUTPUT AGE,MILES,VALUE,$PREDICTED,$RESIDUAL
  781.  
  782.               OUTPUT TO GROWTH.DAT $OBS,TIME,POPULATN,$PREDICTED
  783.  
  784.          POUTPUT file  (optional) -- The POUTPUT  command  specifies  that
  785.               Nonlin  is  to  write  the  final  estimated  values  of the
  786.               parameters to a file.  Each parameter value is written to  a
  787.               separate line of the file.  This command is useful to create
  788.               a  file of estimated parameter values to be fed into another
  789.               analysis program.
  790.  
  791.          PLOT [options]  (optional) -- Display a plot  of  the  calculated
  792.               function and the data observations.  The PLOT command may be
  793.               used   only  if  there  is  a  single  independent  variable
  794.               (multiple   independent   variables   would    require    an
  795.               n-dimensional   surface   plot);   however,   there   is  no
  796.  
  797.                 NONLIN -- Nonlinear Regression Program      Page 15
  798.  
  799.  
  800.               restriction on the number  of  parameters  being  estimated.
  801.               You must have a CGA, EGA, or VGA monitor  to  use  the  PLOT
  802.               command, and the NONLIN.FON font file must be in the current
  803.               directory   or  in  a  directory  specified  by  the  NONLIN
  804.               environment variable.  In the  plot,  the  data  values  you
  805.               provided  are  shown  as blue X's and the function fitted to
  806.               the data by Nonlin is shown as a solid green  line.    Press
  807.               Return  to proceed with the analysis after you have finished
  808.               looking at the plot.
  809.  
  810.               The following options may be specified on the PLOT command:
  811.  
  812.               GRID -- display grid lines to make  it  easier  to  estimate
  813.               values.
  814.  
  815.               RESIDUAL  --  draw  vertical  lines  from each observed data
  816.               point to the corresponding point on the calculated  function
  817.               line.   These  lines  represent  the  "residual"  value that
  818.               Nonlin is attempting to minimize.  See also the descriptions
  819.               of the RPLOT and NPLOT commands.
  820.  
  821.               ITERATION  --  draw  a  plot  for  each  iteration  of   the
  822.               regression analysis.   Normally, the plot is drawn after the
  823.               analysis has converged  to  a  solution;  you  may  use  the
  824.               ITERATION   option  to  observe  the  function  during  each
  825.               iteration of the analysis as it converges to fit the data.
  826.  
  827.               VALUES -- use in conjunction with the  ITERATION  option  to
  828.               cause  the  current  parameter values to be displayed before
  829.               the plot for the current iteration.
  830.  
  831.               PRINT -- print a copy of the plot on an HP LaserJet printer.
  832.               Nonlin writes the plot to  the  PRN  device  which  much  be
  833.               attached to  an  HP  Series  II  or Series III printer.  The
  834.               NONLIN.LJF font file must be in the current directory or  in
  835.               a directory specified by the NONLIN environment variable.
  836.  
  837.               NOPAUSE  --  do  not  pause  after  the  plot  is displayed.
  838.               Normally, Nonlin pauses after displaying a plot to allow you
  839.               time to examine it; you press Enter  to  continue  execution
  840.               once you  have  finished  looking  at the plot.  The NOPAUSE
  841.               option causes Nonlin  to  continue  with  execution  without
  842.               pausing after  the  plot  is  displayed.   This is useful in
  843.               conjunction with the PRINT option when Nonlin is  run  in  a
  844.               batch  file and you want to generate a hardcopy plot but not
  845.               pause after the screen display.
  846.  
  847.               The option  keywords  may  be  abbrievated  to  their  first
  848.               letter.  If more than one option is specified, separate them
  849.               with commas.   For example, to produce a plot with both grid
  850.               lines and residual lines, use the following command:
  851.  
  852.                NONLIN -- Nonlinear Regression Program      Page 16
  853.  
  854.  
  855.                   PLOT GRID,RESIDUAL
  856.  
  857.          RPLOT  [options]  (optional)  --  Display  a plot of the residual
  858.               values.  A "residual" value  (or  error  deviation)  is  the
  859.               difference between an actual value of the dependent variable
  860.               for  an  observation  and  the  predicted value based on the
  861.               function fitted  by  the  regression  analysis.     If   the
  862.               calculated function exactly predicted the actual observation
  863.               values, all  of the residual values would be zero.  However,
  864.               this is usually not the case and the  residual  values  show
  865.               where, and by how much, the fitted function fails to predict
  866.               the actual observations.
  867.  
  868.               The  RPLOT  command  causes Nonlin to display a plot showing
  869.               the residual  values  on  the  vertical  (Y)  axis  and  the
  870.               independent  variable  values  on  the  horizontal (X) axis.
  871.               However, if there is more  than  one  independent  variable,
  872.               Nonlin displays the residual values on the vertical (Y) axis
  873.               and  the  dependent  variable  values  on the horizontal (X)
  874.               axis.  The plot title indicates if  the  dependent  variable
  875.               was used for the X axis.
  876.  
  877.               A  residual  plot is very useful for determining if the form
  878.               of the function being fitted is  appropriate  for  the  data
  879.               values.   If the residual values are randomly distributed in
  880.               positive and negative directions then the  form  (shape)  of
  881.               the fitted function is probably appropriate for the data and
  882.               the deviations  are  due  to random measurement errors.  If,
  883.               however, the residuals show a systematic pattern such  as  a
  884.               periodic cycle, then the function may not be appropriate for
  885.               the data  values.    See the discussion of the Durbin-Watson
  886.               statistic for additional  information  about  autocorrelated
  887.               residual values.  The PLOT, RPLOT, and NPLOT commands may be
  888.               used in the same command file.  Press Return to proceed with
  889.               the analysis after you have finished looking at the plot.
  890.  
  891.               The following options may be specified on the RPLOT command:
  892.  
  893.               GRID  --  display  grid  lines to make it easier to estimate
  894.               values.
  895.  
  896.               PRINT -- print a copy of the plot on an HP LaserJet printer.
  897.               Nonlin writes the plot to  the  PRN  device  which  much  be
  898.               attached to an HP Series II or Series III printer.
  899.  
  900.               NOPAUSE  --  do  not  pause  after  the  plot  is displayed.
  901.               Normally, Nonlin pauses after displaying a plot to allow you
  902.               time to examine it; you press Enter  to  continue  execution
  903.               once you  have  finished  looking  at the plot.  The NOPAUSE
  904.               option causes Nonlin  to  continue  with  execution  without
  905.               pausing after the plot is displayed.
  906.  
  907.                NONLIN -- Nonlinear Regression Program      Page 17
  908.  
  909.  
  910.               The  option  keywords  may  be  abbrievated  to  their first
  911.               letter.  If more than one option is specified, separate them
  912.               with commas.
  913.  
  914.          NPLOT  [options]  (optional) -- Display a normal probability plot
  915.               of the residual values.  In this plot, the actual  value  of
  916.               each  residual  is  plotted on the vertical (Y) axis and the
  917.               expected value of the residual, assuming the  residuals  are
  918.               normally distributed, is plotted on the horizontal (X) axis.
  919.               If  the  residuals  are  normally distributed, the resulting
  920.               plot will be a straight line passing through the origin with
  921.               a slope of 1 (i.e., the actual value of each residual should
  922.               equal the expected value from the normal distribution).   If
  923.               the  residuals  are  not normally distributed, the plot will
  924.               deviate from a straight line.
  925.  
  926.               This plot also computes the correlation between  the  actual
  927.               residual  values  and their expected values and displays the
  928.               correlation coefficient in the title line  "(r=n.nn)".    If
  929.               the   residual   values   are   normally   distributed,  the
  930.               correlation should be close to 1.00.   A  correlation  value
  931.               less  than 0.94 suggests that the residuals are not normally
  932.               distributed.
  933.  
  934.               The NPLOT command may be used even if there is more than one
  935.               independent variable.  The PLOT, RPLOT, and  NPLOT  commands
  936.               may be  used  in  the  same  command  file.  Press Return to
  937.               proceed with the analysis after you have finished looking at
  938.               the plot.
  939.  
  940.               The following options may be specified on the NPLOT command:
  941.  
  942.               GRID -- display grid lines to make  it  easier  to  estimate
  943.               values.
  944.  
  945.               PRINT -- print a copy of the plot on an HP LaserJet printer.
  946.               Nonlin  writes  the  plot  to  the  PRN device which much be
  947.               attached to an HP Series II or Series III printer.
  948.  
  949.               NOPAUSE -- do not pause after the plot is displayed.
  950.  
  951.               The option  keywords  may  be  abbrievated  to  their  first
  952.               letter.  If more than one option is specified, separate them
  953.               with commas.
  954.  
  955.          DOMAIN lowvalue,highvalue (optional) -- Specifies the domain over
  956.               which the  plot is to be generated.  If the DOMAIN statement
  957.               is omitted, the domain of the independent variable  is  used
  958.               for the  plot.  The DOMAIN statement can be used to generate
  959.               a  plot  of  the  fitted  function  extrapolated  over   the
  960.               specified domain.    You  can also use the DOMAIN command to
  961.               restrict the domain and "zero in" on a particular  range  of
  962.               the function.    The  DOMAIN  command  only affects the PLOT
  963.  
  964.                NONLIN -- Nonlinear Regression Program      Page 18
  965.  
  966.  
  967.               command; it does not affect the regresson calculation or the
  968.               RPLOT or NPLOT commands.
  969.  
  970.          DATA  [file]  (required)  --  Specifies  the  name  of  the  file
  971.               containing the data records, or introduces the data  records
  972.               which follow  the  command.   If a file name is specified on
  973.               the DATA command, the file is opened, its data  records  are
  974.               read, and  the  regression analysis is performed.  If a file
  975.               name is specified without an extension, ".DAT"  is  used  by
  976.               default.
  977.  
  978.               If  no  file name is specified on the DATA command, the data
  979.               records must immediately follow  the  DATA  command  in  the
  980.               command file.
  981.  
  982.               Each  data  record must contain at least as many data values
  983.               as the  number  of  variables  specified  on  the  VARIABLES
  984.               command(s).   The order of the variables as specified on the
  985.               VARIABLES command must match the order of the values in each
  986.               observation.  Any data values beyond those required for  the
  987.               specified variables  are  ignored.    Each  observation must
  988.               begin on a new line.
  989.  
  990.               The data values must be separated  by  one  or  more  spaces
  991.               and/or a  comma.  Data values may contain decimal points and
  992.               may be expressed in exponential notation (i.e., n.nnnnEppp).
  993.               As a convenience  for  entering  time  values,  if  a  value
  994.               contains  one or more colons, the portion to the left of the
  995.               colon is multiplied by 60.  For example, 1:00 is  equivalent
  996.               to 60; 1:00:00 is equivalent to 3600.
  997.  
  998.               You may continue data lines by specifying a semicolon as the
  999.               last  non-blank  character  on a record and then placing the
  1000.               continuation value on the following line(s).
  1001.  
  1002.               The DATA command must be the last  command  in  the  command
  1003.               file.  If no file name is specified on the DATA command, the
  1004.               data records must immediately follow the DATA command in the
  1005.               command file.
  1006.  
  1007.               The  following  is  an  example  of  a complete command file
  1008.               including data records:
  1009.  
  1010.               VARIABLES AGE,MILES,VALUE
  1011.               PARAMETERS BASE,DEPAGE,DEPMILES
  1012.               FUNCTION VALUE = BASE + DEPAGE*AGE + DEPMILES*MILES
  1013.               DATA
  1014.               2  10000  13000
  1015.               4  42000   9000
  1016.               1   7000  17000
  1017.               6  52000   6000
  1018.               5  48000   8000
  1019.  
  1020.                NONLIN -- Nonlinear Regression Program      Page 19
  1021.  
  1022.  
  1023.               If the data records had been placed in a separate file named
  1024.               CAR.DAT,   the   DATA   statement   would   be   changed  to
  1025.               "DATA CAR.DAT".
  1026.  
  1027.                NONLIN -- Nonlinear Regression Program      Page 20
  1028.  
  1029.  
  1030.          UNDERSTANDING THE RESULTS
  1031.  
  1032.          Nonlin  prints  a  variety  of  statistics  at  the  end  of each
  1033.          analysis.  For each variable, Nonlin lists the minimum value, the
  1034.          maximum value, the mean value, and the standard deviation.    You
  1035.          should  confirm  that  these  values  are  within  the ranges you
  1036.          expect.
  1037.  
  1038.          For  each  parameter,  Nonlin  displays  the  initial   parameter
  1039.          estimate  (which  you specified on the PARAMETER command, or 1 by
  1040.          default), the final (maximum likelihood) estimate,  the  standard
  1041.          error  of  the  estimated  parameter  value,  the  "t"  statistic
  1042.          comparing the  estimated  parameter  value  with  zero,  and  the
  1043.          significance of the t statistic.
  1044.  
  1045.          The  final  estimate  parameter  values  are  the  results of the
  1046.          analysis.  By substituting  these  values  in  the  equation  you
  1047.          specified to be fitted to the data, you will have a function that
  1048.          can  be used to predict the value of the dependent variable based
  1049.          on a set of values for the independent variables.   For  example,
  1050.          if the equation being fitted is
  1051.  
  1052.          y = p0 + p1*x
  1053.  
  1054.          and  the  final  estimates  are 1.5 for p0 and 3 for p1, then the
  1055.          equation
  1056.  
  1057.          y = 1.5 + 3*x
  1058.  
  1059.          is the best equation of this form that will predict the value  of
  1060.          y based on the value of x.
  1061.  
  1062.          The  "t" statistic is computed by dividing the estimated value of
  1063.          the parameter by its standard error.  This statistic is a measure
  1064.          of the likelihood that the actual value of the parameter  is  not
  1065.          zero.   The  larger the absolute value of t, the less likely that
  1066.          the actual value of the parameter could be zero.
  1067.  
  1068.          The "Prob(t)" is the probability that the  actual  value  of  the
  1069.          parameter could  be  zero.  The smaller the value of Prob(t), the
  1070.          more significant  the  parameter.    For  example,   assume   the
  1071.          estimated  value  of a parameter is 1.0 and its standard error is
  1072.          0.7.  Then the t value would be 1.43 (1.0/0.7).  If the  computed
  1073.          Prob(t)  value  was 0.05 then this indicates that there is only a
  1074.          0.05 (5%) chance that the actual value of the parameter could  be
  1075.          zero.  If Prob(t) was 0.001 this indicates there is only 1 chance
  1076.          in 1000  that  the  parameter could be zero.  If Prob(t) was 0.92
  1077.          this indicates that there is a 92% probability  that  the  actual
  1078.          value  of the parameter could be zero; this implies that the term
  1079.          of the  regression  equation  containing  the  parameter  can  be
  1080.          eliminated  without  significantly  affecting the accuracy of the
  1081.          regression.  The t statistic  probability  is  computed  using  a
  1082.          two-sided test.    The  CONFIDENCE  command  can be used to cause
  1083.  
  1084.                 NONLIN -- Nonlinear Regression Program      Page 21
  1085.  
  1086.  
  1087.          Nonlin to print confidence intervals for parameter values.    The
  1088.          SQUARE.NLR example regression includes  an  extraneous  parameter
  1089.          (p0)  whose  estimated  value  is  much smaller than its standard
  1090.          error; the Prob(t) value is 0.99982 indicating that  there  is  a
  1091.          high probability that the value is zero.
  1092.  
  1093.          In addition to the variable and parameter values, Nonlin displays
  1094.          several  statistics  that indicate how well the equation fits the
  1095.          data.  The "Final sum of squared deviations" is the  sum  of  the
  1096.          squared  differences  between  the  actual value of the dependent
  1097.          variable for each observation and  the  value  predicted  by  the
  1098.          function, using the final parameter estimates.
  1099.  
  1100.          The  "Average  deviation" is the average over all observations of
  1101.          the absolute value of the difference between the actual value  of
  1102.          the dependent variable and its predicted value.
  1103.  
  1104.          The  "Maximum  deviation  for  any  observation"  is  the maximum
  1105.          difference (ignoring sign) between the actual and predicted value
  1106.          of the dependent variable for any observation.
  1107.  
  1108.          The "Proportion of variance explained (R^2)" indicates  how  much
  1109.          better  the  function  predicts  the dependent variable than just
  1110.          using the mean value of the dependent variable.    This  is  also
  1111.          known as  the  "coefficient  of  multiple  determination."  It is
  1112.          computed as follows: Suppose that we did not fit an  equation  to
  1113.          the  data  and  ignored  all  information  about  the independent
  1114.          variables in each observation.  Then, the best prediction for the
  1115.          dependent variable value for any observation would  be  the  mean
  1116.          value of  the  dependent  variable  over  all  observations.  The
  1117.          "variance" is the sum of the squared differences between the mean
  1118.          value  and  the  value  of  the  dependent  variable   for   each
  1119.          observation.   Now,  if we use our fitted function to predict the
  1120.          value of the dependent  variable,  rather  than  using  the  mean
  1121.          value,  a  second  kind of variance can be computed by taking the
  1122.          sum of the squared difference between the value of the  dependent
  1123.          variable   predicted  by  the  function  and  the  actual  value.
  1124.          Hopefully, the variance computed by using the values predicted by
  1125.          the function is better (i.e., a smaller value) than the  variance
  1126.          computed using  the  mean  value.    The  "Proportion of variance
  1127.          explained" is computed as 1 - (variance using  predicted  value /
  1128.          variance using  mean).    If  the function perfectly predicts the
  1129.          observed data, the value of this statistic will be  1.00  (100%).
  1130.          If  the function does no better a job of predicting the dependent
  1131.          variable than using the mean, the value will be 0.00.
  1132.  
  1133.          The "adjusted coefficient of multiple determination (Ra^2)" is an
  1134.          R^2 statistic adjusted  for  the  number  of  parameters  in  the
  1135.          equation and  the  number  of  data  observations.   It is a more
  1136.          conservative estimate  of  the  percent  of  variance  explained,
  1137.          especially  when  the sample size is small compared to the number
  1138.          of parameters.  It is computed using the formula:
  1139.  
  1140.                NONLIN -- Nonlinear Regression Program      Page 22
  1141.  
  1142.  
  1143.                Ra^2 = 1 - (n-1)/(n-p) * (1-R^2)
  1144.  
  1145.          where  `n'  is  the  number of observations, `p' is the number of
  1146.          parameters, and `R^2' is the unadjusted coefficient  of  multiple
  1147.          determination.
  1148.  
  1149.          The  "Durbin-Watson test for autocorrelation" is a statistic that
  1150.          indicates the likelihood that the deviation  (error)  values  for
  1151.          the regression  have a first-order autoregression component.  The
  1152.          regression  models  assume  that   the   error   deviations   are
  1153.          uncorrelated.    In   business  and  economics,  many  regression
  1154.          applications involve  time  series  data.    If  a   non-periodic
  1155.          function, such as a straight line, is fitted to periodic data the
  1156.          deviations  have  a  periodic  form and are positively correlated
  1157.          over time; these deviations are said to  be  "autocorrelated"  or
  1158.          "serially correlated."      Autocorrelated  deviations  may  also
  1159.          indicate that the form (shape) of the function  being  fitted  is
  1160.          inappropriate for the data values (e.g., a linear equation fitted
  1161.          to quadratic data).
  1162.  
  1163.          If  the  deviations  are autocorrelated, there may be a number of
  1164.          consequences  for  the  computed  results:   1)   The   estimated
  1165.          regression  coefficients  no  longer  have  the  minimum variance
  1166.          property;  2)  the  mean  square  error   (MSE)   may   seriously
  1167.          underestimate  the  variance  of the error terms; 3) the computed
  1168.          standard  error   of   the   estimated   parameter   values   may
  1169.          underestimate the true standard error, in which case the t values
  1170.          and confidence  intervals  may  be  incorrect.    Note that if an
  1171.          appropriate periodic function is fitted  to  periodic  data,  the
  1172.          deviations  from  the regression will be uncorrelated because the
  1173.          cycle of the data values is accounted for by the fitted function.
  1174.  
  1175.          Small values of the Durbin-Watson statistic indicate the presence
  1176.          of autocorrelation.    Consult  significance  tables  in  a  good
  1177.          statistics  book for exact interpretations; however, a value less
  1178.          than 0.80 usually indicates that autocorrelation is likely.    If
  1179.          the  Durbin-Watson  statistic  indicates that the residual values
  1180.          are autocorrelated, it is recommended  that  you  use  the  RPLOT
  1181.          and/or NPLOT commands to display a plot of the residual values.
  1182.  
  1183.          If  an NPLOT command is used to produce a normal probability plot
  1184.          of the residuals, the correlation between the residuals and their
  1185.          expected values  (assuming  they  are  normally  distributed)  is
  1186.          printed in   the   listing.     If  the  residuals  are  normally
  1187.          distributed, the  correlation  should  be  close  to  1.00.     A
  1188.          correlation  less  than  0.94 suggests that the residuals are not
  1189.          normally distributed.
  1190.  
  1191.          An "Analysis of Variance" table  provides  statistics  about  the
  1192.          overall significance of the model being fitted.
  1193.  
  1194.                 NONLIN -- Nonlinear Regression Program      Page 23
  1195.  
  1196.  
  1197.          THEORY OF OPERATION
  1198.  
  1199.          Nonlin uses a model/trust-region technique along with an adaptive
  1200.          choice of the model Hessian.   The  algorithm  is  essentially  a
  1201.          combination  of  Gauss-Newton  and  Levenberg-Marquardt  methods;
  1202.          however, the adaptive algorithm  often  works  much  better  than
  1203.          either of these methods alone.
  1204.  
  1205.          The  basis  for  the  minimization technique used by Nonlin is to
  1206.          compute the sum of the squared residuals for one set of parameter
  1207.          values and then slightly alter each parameter value and recompute
  1208.          the sum of squared residuals  to  see  how  the  parameter  value
  1209.          change affects the sum of the squared residuals.  By dividing the
  1210.          difference  between  the original and new sum of squared residual
  1211.          values by the amount the parameter was altered, Nonlin is able to
  1212.          determine the approximate partial derivative with respect to  the
  1213.          parameter.   This  partial derivative is used by Nonlin to decide
  1214.          how to alter the value of the parameter for the next iteration.
  1215.  
  1216.          If the function being modeled is well behaved, and  the  starting
  1217.          value  for  the  parameter is not too far from the optimum value,
  1218.          the procedure will eventually converge to the best  estimate  for
  1219.          the parameter.   This procedure is carried out simultaneously for
  1220.          all parameters  and  is,  in  fact,  a  minimization  problem  in
  1221.          n-dimensional space, where `n' is the number of parameters.
  1222.  
  1223.          For  a much more detailed explanation of the regression algorithm
  1224.          used by Nonlin see ACM Transactions on Mathematical Software  7,3
  1225.          (Sept.  1981)  "Dennis,  J.E.,  Gay, D.M., and Welsch, R.E. -- An
  1226.          adaptive nonlinear least-squares algorithm."
  1227.  
  1228.  
  1229.          CONVERGENCE CRITERION
  1230.  
  1231.          Nonlin has several convergence criterion that stop the  iterative
  1232.          minimization procedure.    The  TOLERANCE  command can be used to
  1233.          alter the convergence tolerance value.
  1234.  
  1235.          Two internal variables are used to determine when convergence has
  1236.          occurred.  RFCTOL has a default value of 1E-10 and can be altered
  1237.          by use of the TOLERANCE command.  AFCTOL has a default  value  of
  1238.          1E-20  and  is only altered by the TOLERANCE command if the value
  1239.          specified is less than the default  value.    In  the  discussion
  1240.          which follows the "function value" is half the sum of the squared
  1241.          residuals computed using the current parameter estimates.
  1242.  
  1243.          "Relative  function  convergence"  is  reported  if the predicted
  1244.          maximum possible function reduction  is  at  most  RFCTOL*ABS(F0)
  1245.          where  F0  is  the  function  value  at  the start of the current
  1246.          iteration, and if the last step attempted achieved no  more  than
  1247.          twice the predicted function decrease.
  1248.  
  1249.                 NONLIN -- Nonlinear Regression Program      Page 24
  1250.  
  1251.  
  1252.          "Absolute function convergence" is reported if the function value
  1253.          is less than AFCTOL.
  1254.  
  1255.  
  1256.          HINTS FOR NONLIN USE
  1257.  
  1258.          Convergence Failures
  1259.  
  1260.          One of  the  potential  problems  that  confronts  any  nonlinear
  1261.          minimization procedure  is  non-convergence.   Non-convergence is
  1262.          usually not a problem for regressions using a linear  model,  but
  1263.          becomes  a  more  serious  consideration  when  using complicated
  1264.          nonlinear  functions;  increasing  the   number   of   parameters
  1265.          aggravates the problem.
  1266.  
  1267.          Non-convergence  can  occur in two ways: the solution may diverge
  1268.          or it may converge to the  wrong  solution  --  a  local  minimum
  1269.          rather than the global minimum.  Periodic functions, such as sin,
  1270.          and cos,  are  particularly  prone  to convergence problems.  For
  1271.          example, consider  a  nonlinear  regression  performed  with  the
  1272.          function:
  1273.  
  1274.          y = offset + amplitude * sin(frequency * x)
  1275.  
  1276.          where x and y are variables, and offset, amplitude, and frequency
  1277.          are the  parameters  whose  values  are to be determined.  If the
  1278.          starting value for frequency  is  not  reasonably  close  to  the
  1279.          correct value, the solution may converge to a harmonic (multiple)
  1280.          or subharmonic  (fundamental)  value of the frequency.  A command
  1281.          file named SINE.NLR is supplied with the  commands  and  data  to
  1282.          perform this analysis.
  1283.  
  1284.          The  SWEEP  command  can  be  very  useful in cases like the sine
  1285.          example.  In the SINE.NLR example analysis, the actual  value  of
  1286.          the  frequency  is  3;  the  function  converges  to  the correct
  1287.          solution if the starting value  is  in  the  range  2.6  to  3.3.
  1288.          However,  this example is quite insensitive to the starting value
  1289.          of the amplitude parameter.  With  an  actual  value  of  2,  the
  1290.          correct  solution  is  found  with starting values from 1 through
  1291.          10000.  Similarly, the offset  parameter,  which  had  an  actual
  1292.          value  of  10,  was  successfully determined with starting values
  1293.          ranging from 1 to over 50000.
  1294.  
  1295.          Another example which is sensitive to a parameter starting  value
  1296.          is  POWER.NLR  which  attempts  to  determine  the  values of the
  1297.          parameters p0, p1, and p2 for the function
  1298.  
  1299.          y = p0 + p1*x^p2
  1300.  
  1301.          (where "x^p2" means x raised to the p2 power).  The actual  value
  1302.          of  p2 in the example data is 2; the solution converges correctly
  1303.          if the starting value of p2 is in the range 1.8 to 3.8.  As  with
  1304.          the  other example, the solution is relatively insensitive to the
  1305.  
  1306.                NONLIN -- Nonlinear Regression Program      Page 25
  1307.  
  1308.  
  1309.          starting values of p0 and p1.
  1310.  
  1311.          Singular Matrix Problems
  1312.  
  1313.          Another  possible  problem is that the analysis may stop with the
  1314.          message "Singular convergence.  Mutually dependent  parameters?".
  1315.          This  is  usually  due  to  one  of  two  things: (1) a redundant
  1316.          parameter that is co-dependent with another parameter, or  (2)  a
  1317.          situation where the value of one parameter "blocks" the effect of
  1318.          other parameters.
  1319.  
  1320.          As an example of a redundant parameter, consider the function
  1321.  
  1322.          y = p0 + p1*p2*x
  1323.  
  1324.          This is a simple linear equation except there are two parameters,
  1325.          p1, and  p2, which are both factors to the variable x.  It should
  1326.          be clear that there is no unique solution to this  problem  since
  1327.          any  value  of p1 is possible if the right value of p2 is chosen.
  1328.          Similarly, the function
  1329.  
  1330.          y = p0 + p1 + p2*x
  1331.  
  1332.          has no unique solution since either p0 or p1 is redundant.
  1333.  
  1334.          Similarly, in the equation
  1335.  
  1336.          y = p0 + p1*exp(x+p2)
  1337.  
  1338.          either p1 or p2 is redundant.
  1339.  
  1340.          The second type of singular matrix problem can be illustrated  by
  1341.          the function
  1342.  
  1343.          y = p0 + p1*x^p2
  1344.  
  1345.          If,  during  the  solution process, p1 takes on the value 0, then
  1346.          varying the value of p2 has no effect on the equation and  Nonlin
  1347.          cannot  figure  out  which  way to change the value of p2 to move
  1348.          toward convergence.  The solution to this problem is to assign  a
  1349.          starting  value  that  is  not  zero to p1, and use the CONSTRAIN
  1350.          command to force p1 to remain non-zero.
  1351.  
  1352.  
  1353.          PERFORMANCE ISSUES
  1354.  
  1355.          Nonlin is carefully programmed and compiled  with  an  optimizing
  1356.          compiler for  maximum  performance.    However,  Nonlin is a real
  1357.          "number cruncher," and  the  nonlinear  regression  algorithm  is
  1358.          mathematically very  elaborate.    During  each iteration, Nonlin
  1359.          computes gradients, Jacobians,  Hessians,  and  eigenvalues,  and
  1360.          performs QR and Cholesky matrix decompositions.  All calculations
  1361.          are carried out using double precision (64 bit) floating point.
  1362.  
  1363.                 NONLIN -- Nonlinear Regression Program      Page 26
  1364.  
  1365.  
  1366.  
  1367.          Nonlin does not require an 80x87  numeric  coprocessor,  but  its
  1368.          performance is  greatly  enhanced if one is present.  In fact, an
  1369.          8088 CPU with an 8087 numeric coprocessor can perform  regression
  1370.          analyses  faster  than  a  20 MHz  80386  that  does  not  have a
  1371.          coprocessor.  If you have  an  8088  without  a  coprocessor,  be
  1372.          patient -- Nonlin is probably giving it the workout of its life.
  1373.  
  1374.          Very  long  running times can result if you use the SWEEP command
  1375.          with many starting values.  The problem is compounded if you have
  1376.          multiple SWEEP commands.  If you use the SWEEP command to  try  a
  1377.          large  number  of starting parameter values, you can save time by
  1378.          using the  ITERATIONS  command  to  specify  a  small  number  of
  1379.          iterations  (such  as  5)  during  the  initial attempt to find a
  1380.          solution.  Once a feasible set of starting parameter  values  has
  1381.          been  determined,  remove the SWEEP command, specify the starting
  1382.          values  on  the  PARAMETERS  command,  increase  the  number   of
  1383.          iterations, and rerun the analysis to get the final result.
  1384.  
  1385.          PROGRAM LIMITS
  1386.  
  1387.          The following is a summary of the Nonlin program limitations:
  1388.  
  1389.          Maximum number of variables = 12
  1390.          Maximum number of parameters = 12
  1391.          Maximum length of variable or parameter names = 10
  1392.  
  1393.          The  maximum  number  of data observations that Nonlin can handle
  1394.          depends on the number of parameters as shown by  the  table  that
  1395.          follows:
  1396.  
  1397.               # Parameters    Max Observations
  1398.                     1               2019
  1399.                     2               1611
  1400.                     3               1339
  1401.                     4               1144
  1402.                     5                997
  1403.                     6                883
  1404.                     7                791
  1405.                     8                715
  1406.                     9                652
  1407.                    10                599
  1408.  
  1409.  
  1410.          EXAMPLE ANALYSES
  1411.  
  1412.          A  number  of example regression analysis files are provided with
  1413.          your Nonlin distribution.  All of the example command files  have
  1414.          the extension  ".NLR".   Some of the important ones are described
  1415.          below, others contain comment lines that explain what they do.
  1416.  
  1417.          LINEAR.NLR -- Simple linear regression with plotted function  and
  1418.               data.
  1419.  
  1420.                 NONLIN -- Nonlinear Regression Program      Page 27
  1421.  
  1422.  
  1423.  
  1424.          QUAD.NLR -- Fit a quadratic equation.  Plot the function and  the
  1425.               data.
  1426.  
  1427.          ASYMPTOT.NLR -- Fit an asymptotic function Y = 12 - 10/X.
  1428.  
  1429.          F33.NLR  -- Multivariate linear regression (multiple regression).
  1430.               Calculate the value of a used  Beech  F33  Bonanza  airplane
  1431.               using  a  linear model based on its age, the number of hours
  1432.               on its airframe, and the number of hours on its engine.  The
  1433.               t value and Prob(t) indicate that the number of hours on the
  1434.               engine  (`Engdep'  parameter)  is  not  signficant  to   the
  1435.               regression  model;  the other parameters are significant but
  1436.               airframe hours is less significant than the base  price  and
  1437.               age of the plane.
  1438.  
  1439.          F33YEAR.NLR -- Similar to F33.NLR except the price of the Bonanza
  1440.               is calculated based on a linear function of only the age.
  1441.  
  1442.          F33EXP.NLR   --   Similar   to   F33YEAR.NLR  except  a  negative
  1443.               exponential function is used rather than a linear  function.
  1444.               Compare  the  fit of this model with that of the F33YEAR.NLR
  1445.               example.
  1446.  
  1447.          SINE.NLR -- Fit an equation involving a sin function.  The  SWEEP
  1448.               command is used to find a starting point that will converge.
  1449.  
  1450.          SQUARE.NLR --  Fit  a sine series to a square wave.  Note in this
  1451.               example  that  the  'p0'  parameter,  which  represents  the
  1452.               constant  term  of  the  equation, has an estimated value of
  1453.               9.22715E-006 (very nearly zero)  and  a  standard  error  of
  1454.               0.0398754.  This yields a t value of nearly zero and Prob(t)
  1455.               of  0.99982  which means that there is a 99.982% chance that
  1456.               the actual value of p0 may be zero (it  is  in  fact  zero).
  1457.               This  illustrates how you can use the t value and Prob(t) to
  1458.               identify extraneous parameters.
  1459.  
  1460.          COOLING.NLR -- Fit an equation involving an exponential function.
  1461.               If a heated object is allowed to cool, the rate  of  cooling
  1462.               at any instant is proportional to the difference between the
  1463.               object's temperature and the ambient (room) temperature.  In
  1464.               other  words,  an  object cools faster at first, while it is
  1465.               hot, and the rate of cooling slows down as  the  temperature
  1466.               of the  object  approaches  the  ambient  temperature.   The
  1467.               function that relates the object's temperature to time is:
  1468.  
  1469.               Temperature = Roomtemp+InitTemp*exp(-Coolrate*Time)
  1470.  
  1471.               Where  InitTemp  is  the  number  of  degrees   above   room
  1472.               temperature at time 0, and Coolrate is a factor that depends
  1473.               on  the  mass  of the object, how well it is insulated, etc.
  1474.               The exp function is the value of e (2.7182818...) raised  to
  1475.               a power.   The COOLING.NLR example determines the parameters
  1476.  
  1477.                 NONLIN -- Nonlinear Regression Program      Page 28
  1478.  
  1479.  
  1480.               InitTemp and Coolrate to fit an equation  of  this  form  to
  1481.               some data the author collected.
  1482.  
  1483.          BOIL.NLR -- The boiling point of water decreases as the  pressure
  1484.               in  the  vessel containing the water decreases. "Clapeyron's
  1485.               equation"  shows  that  the  boiling  point  is  related  to
  1486.               pressure according to the following function:
  1487.  
  1488.               Temperature = b / log(Pressure/a) - 459.7
  1489.  
  1490.               Where  `Temperature'  is  in  degrees  Fahrenheit (the 459.7
  1491.               constant converts degrees Fahrenheit to degrees  Rankine  --
  1492.               relative  to  absolute  zero), `Pressure' is the pressure in
  1493.               the vessel in pounds per square inch, and `a'  and  `b'  are
  1494.               parameters whose  values are to be determined.  The data for
  1495.               this example was collected by the author's son for a science
  1496.               project.
  1497.  
  1498.          MAGNET.NLR -- Fit a function  involving  an  arc  tangent  and  a
  1499.               variable to the third power.  This is an interesting physics
  1500.               problem.   If  a magnet is placed due east of a compass, the
  1501.               deflection of the compass needle from north is equal to  the
  1502.               arc  tangent  of  the  ratio of the strength of the magnet's
  1503.               field relative to the earth's magnetic field.  The  strength
  1504.               of   the   magnet's   field  at  the  compass  is  inversely
  1505.               proportional to the cube of the distance from the magnet  to
  1506.               the compass.  Thus, the function relating these terms is
  1507.  
  1508.               Deflection = deg(atan(Strength / Distance ^ 3))
  1509.  
  1510.               The  deg  function  converts an angle in radians to degrees.
  1511.               In the example, Deflection and Distance are  the  variables,
  1512.               and the value of the Strength parameter is determined.
  1513.  
  1514.          DIODE.NLR -- The current through a diode increases sharply as the
  1515.               voltage across  the  diode  is  increased.  An equation that
  1516.               approximates the current flow as a function of  the  voltage
  1517.               is:
  1518.  
  1519.                       I = exp(b*(V-c))
  1520.  
  1521.               where  `I'  is the current, `V' is the voltage, and `b', and
  1522.               `c' are parameters that are to be estimated by the nonlinear
  1523.               regression.
  1524.  
  1525.          AVLTIME.NLR -- An AVL tree is a  balanced  binary  tree  used  to
  1526.               store information  in  a  computer's  memory.    Because the
  1527.               entries in an AVL tree are kept in  sorted  order,  and  the
  1528.               tree  is  kept in a balanced form, it is possible to rapidly
  1529.               find any entry in the tree.  The time required to create  an
  1530.               AVL tree with N entries is approximately equal to:
  1531.  
  1532.                 NONLIN -- Nonlinear Regression Program      Page 29
  1533.  
  1534.  
  1535.                        Time = a + b*N*log2(N)
  1536.  
  1537.               where `a' is a constant term equal to the overhead  involved
  1538.               in  starting  and  completing  a tree creation, and `b' is a
  1539.               growth  coefficient  that  depends  on  the  speed  of   the
  1540.               computer.   The log2(N) function is the log base 2 of N (the
  1541.               number of  entries).    The  AVLTIME.NLR  example  fits   an
  1542.               equation  to  a  data  set  that relates the time in seconds
  1543.               required to create an AVL tree with the number of entries in
  1544.               the tree.
  1545.  
  1546.          PIECE.NLR --  Piecewise  linear  function.     Fit   a   function
  1547.               consisting of two linear pieces that bend at X=5.  When X is
  1548.               less than  5,  the  slope  of the function is B1.  When X is
  1549.               greater than or equal to 5, the slope is B2.  B0  is  the  Y
  1550.               value  of  the  function  at X=5 (i.e., at the pivot point).
  1551.               The step(a,x) function returns the value 0 when  x  is  less
  1552.               than  `a';  it  returns 1 when x is greater than or equal to
  1553.               `a'.
  1554.  
  1555.  
  1556.          NONLIN USE FOR ROOT FINDING AND FUNCTION MINIMIZATION
  1557.  
  1558.          Although it is designed for nonlinear regression analysis, Nonlin
  1559.          can also be used  to  find  the  root  (zero  point)  or  minimum
  1560.          absolute value  of a nonlinear expression.  To use Nonlin in this
  1561.          fashion  follow  these  steps:  (1)  Do  not  use  any   VARIABLE
  1562.          statements; (2) Use PARAMETER statements to specify the names and
  1563.          optional  starting  values for the parameters whose values are to
  1564.          be determined as the roots or minimum value  of  the  expression;
  1565.          (3)  Use  the  FUNCTION statement to specify the expression whose
  1566.          roots or minimum value is to be found; do NOT specify a dependent
  1567.          variable and equal sign -- specify only the expression that is to
  1568.          be minimized; (4) Do not include any data records after the  DATA
  1569.          statement;  it  simply  signals  the  end of the command file and
  1570.          causes the analysis to begin.
  1571.  
  1572.          The following is an example command file to find the root of  the
  1573.          expression SIN(X)-LOG(X):
  1574.  
  1575.              PARAMETER X
  1576.              FUNCTION SIN(X) - LOG(X)
  1577.              DATA
  1578.  
  1579.          Notice  that the "variable" in the expression, X, is not declared
  1580.          to be a variable  but  rather  a  parameter.    This  example  is
  1581.          included in the file MINSL.NLR which you can run.
  1582.  
  1583.          For  this  type  of analysis, Nonlin determines the values of the
  1584.          parameters that minimize the absolute value  of  the  expression.
  1585.          If  the expression has a zero value (i.e., a root), that value is
  1586.          found since that is the smallest possible absolute value.  If the
  1587.          expression does not have a  zero  point,  Nonlin  determines  the
  1588.  
  1589.                 NONLIN -- Nonlinear Regression Program      Page 30
  1590.  
  1591.  
  1592.          values of the parameters that produce the smallest absolute value
  1593.          of the expression.  For example, the expression 2*x^2-3*x+10 does
  1594.          not have a root but reaches a minimum value of 8.875  when  x  is
  1595.          0.75.  The MINPAROB.NLR command file contains this example.
  1596.  
  1597.          There  are a number of cautions that you should keep in mind when
  1598.          using Nonlin to find roots or minimum values:
  1599.  
  1600.          1. Nonlin will find only one root or minimum value per  analysis.
  1601.             For  example,  the  expression 9-x^2 has two roots: -3 and +3.
  1602.             Nonlin will find one of the roots; which one it finds  depends
  1603.             on the starting value specified for X.
  1604.  
  1605.          2. Nonlin will find only real roots, not complex.
  1606.  
  1607.          3. If the expression contains a local minimum, Nonlin may find it
  1608.             rather than the global minimum or root.  Of course, if you are
  1609.             looking  for a local minimum in a certain region this could be
  1610.             considered a   feature.      For   example,   the   expression
  1611.             0.5*x^3+5*(x-2)^2+15  has a local minimum at x=1.61 and a root
  1612.             at x=-13.38.  If the starting value of x is less than -8.3 the
  1613.             root is found; if the starting value is greater than -8.3, the
  1614.             local minimum is found.  If the  expression  contains  only  a
  1615.             single  variable,  use  the  Mathplot  program  to graphically
  1616.             display the expression and determine a good starting value for
  1617.             the variable (see the end  of  this  document  for  additional
  1618.             information about  Mathplot).    The SWEEP command can also be
  1619.             used to try multiple starting  values  when  searching  for  a
  1620.             global minimum.
  1621.  
  1622.          FUNCTION MINIMIZATION EXAMPLES
  1623.  
  1624.          MINFALL.NLR  --  The  time  taken  for  an object to slide down a
  1625.               frictionless guide from position (0,h) to  another  position
  1626.               (d,0)  (i.e.,  it  falls through a distance `h' while moving
  1627.               horizontally a distance `d') depends on the  path  that  the
  1628.               object takes as it follows the guide.  It turns out that the
  1629.               path  that minimizes the descent time is not a straight line
  1630.               from (0,h) to (d,0) but rather a curve with a steeper  slope
  1631.               near  the  beginning,  that  gives  the  object  a chance to
  1632.               accelerate quickly, and then a shallower slope  further  on.
  1633.               Finding  the shape of this curve is a classic problem in the
  1634.               branch of mathematics called  the  Calculus  of  Variations.
  1635.               The  MINFALL  example solves a simpler case of this problem:
  1636.               the object slides along a straight guide from  (0,h)  to  an
  1637.               intermediate   position  (px,py),  and  then  along  another
  1638.               straight guide from (px,py) to (d,0).  What point,  (px,py),
  1639.               minimizes the descent time?
  1640.  
  1641.          MINFUEL.NLR  --  A  lunar lander is hovering above the surface of
  1642.               the moon looking for a suitable  landing  site.    Available
  1643.               fuel  is  critical  and the desired site is 200 meters away.
  1644.               How long should the horizontal thruster be  fired  to  start
  1645.  
  1646.                NONLIN -- Nonlinear Regression Program      Page 31
  1647.  
  1648.  
  1649.               and stop  the motion over the ground?  The vertical thruster
  1650.               must  be  used  continuously  to  keep the lander from being
  1651.               pulled to the surface.  If too little horizontal  thrust  is
  1652.               used  the  spacecraft will move slowly and much fuel will be
  1653.               consumed  by  the  vertical  thruster  counterbalancing  the
  1654.               downward gravitational pull while hovering over the surface.
  1655.               On the other hand, if the horizontal thruster is fired for a
  1656.               a  long  time,  the spacecraft will move quickly (minimizing
  1657.               the hovering time) but excessive fuel will  be  used  during
  1658.               the horizontal  acceleration  and deceleration.  MINFUEL.NLR
  1659.               determines how long the thruster should be fired during  the
  1660.               start  and  stop  accelerations  such  that  the  total fuel
  1661.               consumption  (start  thrust  +  stop  thrust  +  hover)   is
  1662.               minimized.
  1663.  
  1664.  
  1665.          ACKNOWLEDGEMENT
  1666.  
  1667.          The  nonlinear  regression algorithm used by Nonlin was published
  1668.          in ACM Transactions on Mathematical  Software  7,3  (Sept.  1981)
  1669.          "Dennis,  J.E.,  Gay,  D.M.,  and  Welsch,  R.E.  --  An adaptive
  1670.          nonlinear least-squares algorithm."
  1671.  
  1672.  
  1673.          USE AND DISTRIBUTION OF NONLIN
  1674.  
  1675.          Nonlin is a "shareware" product.  You are welcome to make  copies
  1676.          of  this program and pass them on to friends or post this program
  1677.          on bulletin boards (in its original, unmodified form).
  1678.  
  1679.          However, if you find Nonlin to  be  useful,  educational,  and/or
  1680.          entertaining you are expected to compensate the author by sending
  1681.          the  registration  form  printed  on  a  following  page  (and in
  1682.          REGISTER.DOC) with the appropriate registration fee to help cover
  1683.          the development and support of  Nonlin.    In  return,  you  will
  1684.          receive  the  most  recent  version  of  the program along with a
  1685.          laser-printed, bound manual.    The  author  frequently  improves
  1686.          Nonlin and it is likely that the version you have is not the most
  1687.          recent version.     Note,  the  cost  of  registering  Nonlin  is
  1688.          insignificant compared  with  what  you  would  have  to  pay  to
  1689.          purchase  a  commercial  statistical  package  with an equivalent
  1690.          regression capability.
  1691.  
  1692.          See also the special offer that follows  involving  the  Mathplot
  1693.          program.
  1694.  
  1695.          You are welcome to write to the author:
  1696.  
  1697.                                 Phillip H. Sherrod
  1698.                                  4410 Gerald Place
  1699.                              Nashville, TN  37205-3806
  1700.                               615-292-2881 (evenings)
  1701.  
  1702.                NONLIN -- Nonlinear Regression Program      Page 32
  1703.  
  1704.  
  1705.          Both  the Nonlin program and documentation are copyright (c) 1992
  1706.          by Phillip  H.  Sherrod.    You  are not authorized to modify the
  1707.          program. "Nonlin" is a trademark.
  1708.  
  1709.          Disclaimer
  1710.  
  1711.          Nonlin is provided "as is" without warranty of any  kind,  either
  1712.          expressed or  implied.    This  program  may  contain  "bugs" and
  1713.          inaccuracies, and its results should not be assumed to be correct
  1714.          unless they are  verified  by  independent  means.    The  author
  1715.          assumes  no  responsibility for the use of Nonlin and will not be
  1716.          responsible for any damage resulting from its use.
  1717.  
  1718.                NONLIN -- Nonlinear Regression Program      Page 33
  1719.  
  1720.  
  1721.  
  1722.  
  1723.                                   M A T H P L O T
  1724.  
  1725.  
  1726.                       Mathematical Function Plotting Program
  1727.  
  1728.  
  1729.                                    Special Offer
  1730.  
  1731.  
  1732.  
  1733.          If  you like Nonlin, you should check out the Mathplot program by
  1734.          the same author.
  1735.  
  1736.          Mathplot allows you to specify complicated mathematical functions
  1737.          using ordinary algebraic expressions and immediately  plot  them.
  1738.          Four  types  of  functions  may be specified: cartesian (Y=f(X));
  1739.          parametric    cartesian    (Y=f(T)     and     X=f(T));     polar
  1740.          (Radius=f(Angle));   and   parametric   polar   (Radius=f(T)  and
  1741.          Angle=f(T)).  Up to four functions may be plotted simultaneously.
  1742.          Scaling is automatic.  Options  are  available  to  control  axis
  1743.          display and labeling as well as grid lines.  Hard copy output may
  1744.          be generated  as  well  as  screen display.  Mathplot is an ideal
  1745.          tool for engineers, scientists, math and  science  teachers,  and
  1746.          anyone   else   who   needs  to  quickly  visualize  mathematical
  1747.          functions.
  1748.  
  1749.  
  1750.          SPECIAL OFFER
  1751.  
  1752.          Registered users of Nonlin can order Mathplot for a special price
  1753.          of $18.  Or, for an even better deal, if you register Nonlin  and
  1754.          order Mathplot at the same time, you can get both for $41.
  1755.  
  1756.                 NONLIN -- Nonlinear Regression Program      Page 34
  1757.  
  1758.  
  1759.        =====================================================================
  1760.                                 Software Order Form
  1761.        =====================================================================
  1762.  
  1763.          NAME ______________________________________________________
  1764.  
  1765.          ADDRESS ___________________________________________________
  1766.  
  1767.          CITY _______________________  STATE _______ ZIP ___________
  1768.  
  1769.          TELEPHONE _________________________________________________
  1770.  
  1771.          NONLIN VERSION ____________________________________________
  1772.  
  1773.          BULLETIN BOARD WHERE YOU FOUND NONLIN _____________________
  1774.  
  1775.          COMMENTS __________________________________________________
  1776.  
  1777.          Check the box below which indicates your order type:
  1778.  
  1779.          ___ I wish to register Nonlin ($25).
  1780.  
  1781.          ___ I wish to order Mathplot ($20).
  1782.  
  1783.          ___ I wish to register Nonlin and order Mathplot ($41).
  1784.  
  1785.          Add $5 to any amount shown above if the software is being shipped
  1786.          out of the United States.
  1787.  
  1788.          In return for registering,  you  will  receive  the  most  recent
  1789.          version  of  the  program  and a laser-printed, bound copy of the
  1790.          manual.
  1791.  
  1792.          Distribution disk choice (check one):
  1793.  
  1794.                3.50" HD (1.4 MB)  ______
  1795.                5.25" HD (1.2 MB)  ______
  1796.                5.25" DD (360 KB)  ______
  1797.  
  1798.          Send this form with the amount indicated to the author:
  1799.  
  1800.                                 Phillip H. Sherrod
  1801.                                  4410 Gerald Place
  1802.                              Nashville, TN  37205-3806
  1803.                               615-292-2881 (evenings)
  1804.